package edu.sctu.zhangwang.month201506.day20150614;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;

/**
 * Created by Administrator on 2015/6/14.
 */
public class CreateFile {

    public void createFile(File file) {
        if (!file.exists()){
            file.mkdirs();
        }

    }
    public void createNewFile(File file) throws IOException {
        if (!file.exists()){
            file.createNewFile();
        }
    }
    public Boolean deleteNewFile(File file) {
        if (file.exists()) {
            file.delete();

            if (!file.delete()) {
                System.out.println("删除文件成功。");
            } else {
                System.out.println("没有删除成功");
            }

        }else {
            System.out.println("文件不存在。");
        }
        return file.delete();
    }
    public void file_list(File file){
        File[] files = file.listFiles();
        for (int i=0;i<files.length;i++){
            System.out.println(files[i]);
        }
    }
    public static void main(String[] args) throws IOException {
        final String file_Path = "E://my_file/";
        final String newfile_Path = file_Path+"/wo.dox";
        final String newfile_Path1 = file_Path+"/zhangwang.txt";

        CreateFile createFile = new CreateFile();
        File file = new File(file_Path);
        File file1 = new File(newfile_Path);
//        createFile.createFile(file);
        createFile.createNewFile(new File(newfile_Path1));
        createFile.createNewFile(file1);
        createFile.file_list(new File(file_Path));
//        createFile.deleteNewFile();

    }
}
